package com.ces.knacky.controller.tools;

import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ces.knacky.framework.controller.BaseController;
import com.ces.knacky.framework.model.IEntity;
import com.ces.knacky.model.Company;
import com.ces.knacky.model.Flag;
import com.ces.knacky.model.UserTable;
@Controller
public class SaveCompanyController extends BaseController {
	
	
	private String description;
	private String website;
	private String summary;
	
	@RequestMapping ("/saveCompany.htm")	
	public String execute(){
		System.out.println("Inside Save Role");
		Company company = new Company();
		company.setDescription(description);
		company.setWebsite(website);
		company.setSummary(summary);
		company.setCreateTime(new Date());
		company.setUpdateTime(new Date());
		IEntity entity = commonService.findFirstByDescription(UserTable.class, "admin");
		company.setUser((UserTable)entity);
		entity = commonService.findFirstByDescription(Flag.class, "ACTIVE");
		company.setFlag((Flag)entity);
		commonService.add(company);
		return "saveCompany";
	}

	/**
	 * @return the description
	 */	
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	@ModelAttribute("description")
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * @return the description
	 */	
	public String getWebsite() {
		return website;
	}
	
	/**
	 * @param description the description to set
	 */
	@ModelAttribute("website")
	public void setWebsite(String website) {
		this.website = website;
	}

	
	/**
	 * @return the description
	 */	
	public String getSummary() {
		return summary;
	}
	
	/**
	 * @param description the description to set
	 */
	@ModelAttribute("summary")
	public void setSummary(String summary) {
		this.summary = summary;
	}



}
